<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客发布</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">
</head>

<body>
<!--导航-->
<nav th:replace="admin/_fragments :: menu(1)" class="ui inverted attached segment m-padded-tb-mini m-shadow-small">
    <div class="ui container">
        <div class="ui inverted secondary stackable menu">
            <h2 class="ui teal header secondary item">管理后台</h2>
            <a href="#" class="active m-item item m-mobile-hide"><i class="idea icon"></i>博客</a>
            <a href="#" class="m-item item m-mobile-hide"><i class="tags icon"></i>分类</a>
            <a href="#" class="m-item item m-mobile-hide"><i class="tags icon"></i>标签</a>
            <div class="right m-item m-mobile-hide menu">
                <div class="ui dropdown item">
                    <div class="text">
                        <img class="ui avatar image" src="../../static/images/avatar.jpg">
                        <b>李桃</b>
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <a href="#" class="ui menu toggle grey icon button m-top-right m-mobile-show">
        <i class="sidebar icon"></i>
    </a>

</nav>

<!--二级导航-->
<div class="ui attached pointing inverted menu">
    <div class="ui container">
        <div class="right menu">
            <a href="#" class="active teal item">发布</a>
            <a href="#" class="teal item">列表</a>
        </div>
    </div>
</div>

<!--中间内容 m-container样式 左右存在间距-->
<div class="m-container m-padded-tb-big">
    <!--根据屏幕的尺寸达到最好的效果 attached浮加  bottom,top圆角-适应移动端-->
    <div class="ui container">

        <form id="blog-form" action="#" th:object="${blog}" th:action="@{/admin/blogs}" method="post" class="ui form">
            <!--选择框和标题-->
            <input type="hidden" name="published" th:value="*{published}">
            <input type="hidden" name="id" th:value="*{id}">
            <input type="hidden" name="praise" th:value="*{praise}">
            <input type="hidden" name="yuck" th:value="*{yuck}">
            <input type="hidden" name="views" th:value="*{views}">
            <div class="required field">
                <div class="ui left labeled input">
                    <div class="ui selection compact dropdown button label"
                         style="background-color: #E0E1E2;z-index: 999!important;">
                        <input type="hidden" value="原创" name="flag" th:value="*{flag}">
                        <i class="dropdown icon"></i>
                        <div class="text">原创</div>
                        <div class="menu">
                            <div class="item" data-value="原创">
                                <div class="ui orange empty circular label"></div>
                                原创
                            </div>
                            <div class="item" data-value="原创/转载">
                                <div class="ui pink empty circular label"></div>
                                原创/转载
                            </div>
                            <div class="item" data-value="转载">
                                <div class="ui blue empty circular label"></div>
                                转载
                            </div>
                        </div>
                    </div>
                    <input type="text" name="title" placeholder="标题" th:value="*{title}"
                           class="required m-text-big-fat">
                </div>
            </div>

            <!--输入内容-->
            <div class="required field">
                <div id="md-content" style="z-index: 998!important;">
                        <textarea placeholder="博客内容" name="content" th:text="*{content}" style="display: none">

                        </textarea>
                </div>
            </div>

            <div class="two fields ">
                <!--文章分类-->
                <div class="field" style="z-index: 999!important;">
                    <div class="required field">
                        <div class="ui left labeled action input">
                            <label class="ui compact pink label">分类</label>
                            <!--                                <div class="ui selection compact dropdown button label m-bolg-release-selection">-->
                            <div class="ui fluid selection dropdown">
                                <input type="hidden" name="typeId" th:value="*{typeId}!=null ? *{typeId}">
                                <i class="dropdown icon"></i>
                                <div class="default text m-opacity-large">分类</div>
                                <div class="menu">
                                    <div th:each="type : ${types}" class="item" data-value="1"
                                         th:data-value="${type.id}" th:text="${type.name}">错误日志
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!--文章标签-->
                <div class="field" style="z-index: 999!important;">
                    <div class="required field">
                        <div class="ui left labeled action input">
                            <label class="ui compact green label">标签</label>
                            <div class="ui multiple selection compact dropdown button label m-bolg-release-selection">
                                <input type="hidden" name="tagIds" th:value="*{tagIds}">
                                <i class="dropdown icon"></i>
                                <div class="aligned default text m-opacity-large">标签</div>
                                <div class="menu">
                                    <div th:each="tag : ${tags}" class="item" data-value="1" th:data-value="${tag.id}"
                                         th:text="${tag.name}">java
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--选择框-->

            <!--首图地址-->
            <div class="required field">
                <div class="ui left labeled input">
                    <label class="ui teal label">首图</label>
                    <input type="text" name="firstPicture" th:value="*{firstPicture}" placeholder="首图引用地址">
                </div>
            </div>
            <div class="required field">
                <textarea name="description" th:text="*{description}" placeholder="博客描述..." maxlength="200"></textarea>
            </div>
            <div class="inline fields">
                <div class="field">
                    <div class="ui toggle checkbox">
                        <input type="checkbox" id="recommend" th:checked="*{recommend}" checked name="recommend">
                        <label for="recommend"><span
                                style="color:Magenta;font-weight:bold;font-size: 18px">推荐</span></label>
                    </div>
                </div>

                <div class="field">
                    <div class="ui toggle checkbox">
                        <input type="checkbox" id="shareStatement" th:checked="*{shareStatement}" name="shareStatement">
                        <label for="shareStatement"><span
                                style="color:MediumSpringGreen;font-weight:bold;font-size: 18px">转载声明</span></label>
                    </div>
                </div>

                <div class="field">
                    <div class="ui toggle checkbox">
                        <input type="checkbox" id="appreciation" th:checked="*{appreciation}" name="appreciation">
                        <label for="appreciation"><span style="color:Crimson;font-weight:bold;font-size: 18px">赞赏</span></label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui toggle checkbox">
                        <input type="checkbox" id="commentSwitch" th:checked="*{commentSwitch}" name="commentSwitch">
                        <label for="commentSwitch"><span
                                style="color:DeepSkyBlue;font-weight:bold;font-size: 18px">评论</span></label>
                    </div>
                </div>
            </div>
            <!--三个按钮 返回 保存 发布-->

            <div class="ui error message"></div>
            <div class="ui right aligned container">
                <!--window.history.go(-1)返回上一级也买你-->
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button type="button" id="save-btn" class="ui primary button">保存</button>
                <button type="button" id="publish-btn" class="ui positive button">发布</button>
            </div>
        </form>
    </div>
</div>

<!--底部footer-->
<footer th:replace="admin/_fragments :: footer" class="ui inverted divided vertical segment m-padded-tb-massive">
    <div class=" ui stackable center aligned container">
        <div class="ui inverted divided stackable grid">
            <!--二维码-->
            <div class="three wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="../../static/images/wechat.jpg" class="ui rounded" style="width: 130px" alt="">
                    </div>
                </div>
            </div>

            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">用户故事 (User Story)</a>
                    <a href="#" class="item">用户故事 (User Story)</a>
                    <a href="#" class="item">用户故事 (User Story)</a>
                </div>
            </div>

            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">联系我</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">Email: 1490477595@qq.com</a>
                    <a href="#" class="item">QQ: 1490477595</a>
                </div>
            </div>

            <div class=" seven wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">博猪寄语</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mini">
                    你遇到的每个人都是别人想见又见不到的人，请珍惜每一刻相处的时光，因为我们不知道哪一次再见，会变成再也不见。</p>
            </div>
        </div>
        <!--线条-->
        <div class="ui inverted section divider"></div>
        <p class="m-text-thin m-text-spaced m-opacity-small">Copyright © 2020 - 2021 AndyLee</p>
    </div>
</footer>
<!--/*/<th:block th:replace="admin/_fragments :: script">/*/-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<script src="../../static/lib/editormd/editormd.min.js" th:src="@{/lib/editormd/editormd.min.js}"></script>
<!--/*/</th:block>/*/-->

<script>
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });
    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    $('#save-btn').click(function () {
        $('[name="published"]').val(false);
        $('#blog-form').submit();
    });


    $('#publish-btn').click(function () {
        $('[name="published"]').val(true);
        $('#blog-form').submit();
    });

    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'title',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入博客标题'
                }]
            },
            content: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入博客内容'
                }]
            },
            type: {
                identifier: 'type',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请选择博客分类'
                }]
            },
            /*    firstPicture : {
                    identifier: 'firstPicture',
                    rules: [{
                        type : 'empty',
                        prompt: '标题：请输入博客首图'
                    }]
                },*/
            description: {
                identifier: 'description',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入博客描述'
                }]
            }
        }
    });
    //初始化Markdown编辑器
    var contentEditor;
    $(function () {
        contentEditor = editormd("md-content", {
            width: "100%",
            height: 640,
            syncScrolling: "single",
            path: "/lib/editormd/lib/"
        });
    });
</script>

</body>
</html>
